package com.tm;

import java.sql.*;

public class JDBCTest02 {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");

            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/tm", "root", "1111");

            Statement statement = connection.createStatement();

            String sql = "update stu set stu_sex = 'fm' where stu_id = 3";

            int i = statement.executeUpdate(sql);

            if (i > 0) {
                System.out.println("修改成功");
            }
            statement.close();
            connection.close();
            System.out.println("连接成功");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
